# -*- coding:  iso-8859-1 -*-
from django.core.management.base import BaseCommand, CommandError
from datetime import date 
from django.conf import settings
from notifications.models import Communication

class Command(BaseCommand):
    args = '[show_errors]'
    help = 'Envío de mails automáticos'

    def handle(self, *args, **options):
        communications = Communication.objects.filter(auto=True)
        for communication in communications:
            print "Communication: %s" % communication
            if len(args) >= 1 and args[0] == "show_errors":
                communication.send_all()
            else:
                try:
                    communication.send_all()
                except:
                    print "Error"

